package leetcode_acm.stackAndQueue;

import org.junit.Test;

/**
 * 功能描述
 *
 * @author: 张庭杰
 * @date: 2023年03月22日 14:38
 */
public class RemoveDuplicates {
    public String removeDuplicates(String ss) {
        char[] s = ss.toCharArray();
        char[] str = new char[s.length];
        int index = -1;
        int p = 0;
        while(p < s.length){
            if(index == -1 || str[index] != s[p]){
                str[++index] = s[p];
            }else{
                index--;
            }
            p++;
        }
        return new String(str,0,index);
    }
    @Test
    public void test(){
        System.out.println(removeDuplicates("abbaca"));
    }
}
